package mjava.lib;

import java.io.Serializable;
import java.util.Vector;

public class DPARAMS implements Serializable {
	private static final long serialVersionUID = -2606318165782323499L;
	private int taille;
	private Vector<DPARAM> paramList;


	public int getTaille() {
		return taille;
	}

	public Vector<DPARAM> getParamList() {
		return this.paramList;
	}

	public DPARAMS() {
		taille = 0;
		paramList = new Vector<DPARAM>();
	}

	public void addParam(DPARAM param) {
		paramList.add(param);
		this.taille += param.getParamTaille();
	}

	public int getParamNumber() {
		return this.paramList.size();
	}

	public String[] getParamsTypeNames() {

		String[] paramsTypeNamesArray  = null;
		int paramsLength = paramList.size();

		if(paramsLength > 0) {

			paramsTypeNamesArray = new String[paramsLength];

			DPARAM param = null;

			for(int i = 0; i < paramsLength; i++) {
				param = paramList.get(i);
				paramsTypeNamesArray[i] = param.getParamType().getName();
			}
		}

		return paramsTypeNamesArray;
	}

	public String getParamsTypeNamesString() {

		String parNameStr = "";

		String[] paramsTypeNamesArray = this.getParamsTypeNames();

		for(int i = 0; i < paramList.size(); i++) {
			parNameStr += "." + paramsTypeNamesArray[i];
		}

		return parNameStr;
	}
	
	public void setParamsDepl() {
		Vector<DPARAM> paramsList = this.paramList;
		DPARAM param = null;
		int tmpTaille = this.taille;
		for(int i = 0; i < paramsList.size(); i++) {
			param = paramsList.get(i);
			param.setParamDepl(-tmpTaille);
			tmpTaille -= param.getParamTaille();
		}
	}
}
